import type { KnowledgeData, KnowledgeParams, DoctorPage, PageParams, FollowType, TopDep, ConsultOrderPreParams, ConsultOrderPreData, PartialConsult, ConsultOrderItem } from '@/types/consult'
import { request } from '@/utils/request'
// 首页-查询推荐/减脂/饮食健康/关注页面--百科文章列表
export function homeKnowledge(obj: KnowledgeParams) {
  return request<KnowledgeData>('get', '/patient/home/knowledge', obj)
}
// 关注的医生列表
export function homePageDoc(obj: PageParams) {
  return request<DoctorPage>('get', '/home/page/doc', obj)
}
// 关注 | 取消关注
export function docLike(id: string, type: FollowType = 'doc') {
  return request('post', '/like', { id, type })
}
// 选择科室列表
export function depAll() {
  return request<TopDep[]>('get', '/dep/all')
}
// 上传图片
// 5. 上传文件/图片
export function uploadImage(file: File) {
  // 将文件管理 到 formData 中
  const fd = new FormData()
  fd.append('file', file)
  return request<{ id: string; url: string }>('POST', '/upload', fd)
}
// 得到就诊信息&支付信息
export const getConsultOrderPre = (params: ConsultOrderPreParams) => request<ConsultOrderPreData>('get', '/patient/consult/order/pre', params)
// 生成订单
export function patientConsultOrder(params: PartialConsult) {
  return request<{ id: string }>('post', '/patient/consult/order', params)
}
// 支付接口
export function patientConsultPay(params: { paymentMethod: string; orderId: string; payCallback: string }) {
  return request<{ payUrl: string }>('post', '/patient/consult/pay', params)
}
// 订单信息
export function getConsultOrderDetail(orderId: string) {
  return request<ConsultOrderItem>('get', '/patient/consult/order/detail', { orderId })
}
// 10. 药品订单-根据处方ID查询处方单
export const getPrescriptionPic = (id: string) => request<{ url: string }>('get', `/patient/consult/prescription/${id}`)
// 评价医生
export function patientOrderEvaluate(data: { docId: string; orderId: string; score: number; content: string; anonymousFlag: 0 | 1 }) {
  return request('post', '/patient/order/evaluate', data)
}
